from selenium import webdriver
from selenium.webdriver.support.select import Select
import time
driver = webdriver.Chrome()
driver.get('file:///D:/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95/%E8%AF%BE%E7%A8%8B%E4%BB%A3%E7%A0%81/day5%E4%BB%A3%E7%A0%81/demo.html')
# driver.find_element_by_class_name('baidu').click()
# time.sleep(2)
# driver.close()

# driver.get('http://www.baidu.com')
# driver.set_window_size(400, 800)
# time.sleep(2)
# driver.maximize_window()
# print(driver.get_window_size()['width'])

# driver.get('http://www.baidu.com')
# driver.get_screenshot_as_file('d://1.png')#浏览器截图
# driver.close()

# profile = webdriver.FirefoxProfile()
# profile.add_extension()
# driver = webdriver.Firefox(firefox_profile=profile)

user = driver.find_element_by_id('user')
user.send_keys('hahahahaha')
time.sleep(2)
user.clear()

print(driver.find_element_by_name('info').text)

href = driver.find_element_by_class_name('baidu').get_attribute('href')
driver.get(href)
driver.find_element_by_id('kw').send_keys('慧测')
time.sleep(2)
driver.get('file:///D:/%E8%87%AA%E5%8A%A8%E5%8C%96%E6%B5%8B%E8%AF%95/%E8%AF%BE%E7%A8%8B%E4%BB%A3%E7%A0%81/day5%E4%BB%A3%E7%A0%81/demo.html')
print(driver.find_element_by_id('img_good').get_attribute('src'))

# driver.find_element_by_link_text('baidu')
# driver.find_element_by_partial_link_text('慧测')
#
#
# print(driver.find_element_by_id('img_good').get_attribute('src'))
#
#
# driver.find_element_by_xpath('//img[@id="img_good"]')